package com.yf.custom.pay;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * @ClassName PayController
 * @Description TODO
 * @Author yf
 * @Date 2018/10/15 11:11
 * @Version 1.0
 */
@RestController
public class PayController {

    /**
     * 根据不同渠道计算价格（便于测试，未处理Exception，小伙伴要根据自己需求处理，不要忘记）
     * @param channelId
     * @return
     */
    @RequestMapping("calculatePrice")
    public String calculatePrice(@RequestParam  Integer channelId, @RequestParam Integer goodsId) throws Exception {
        PayChannelContext context=new PayChannelContext();
        BigDecimal bigDecimal= context.calRecharge(channelId,goodsId);
        return bigDecimal.setScale(2)+"";
    }
}
